package com.atmilan.quartz.utils;

import com.atmilan.quartz.model.entity.crmeb.SyncProductLogs;
import com.atmilan.quartz.service.IStoreProductService;
import com.atmilan.quartz.service.ISyncProductLogsService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
 * 定时任务商品日志类
 * @Description:
 * @author daigb
 * @date 2021-03-12
 */
@Slf4j
@Service
public class LogsUtil {

    @Autowired
    ISyncProductLogsService syncProductLogsService;

    @Autowired
    IStoreProductService storeProductService;

    /**
     * 保持日志记录
     * @Description:
     * @author daigb
     * @param @param goodsNo
     * @param @param skuBarcode
     * @param @throws Exception
     * @return void
     * @throws
     */
    public void insertSyncProductLogs(String goodsNo,
                                      String goodsName, String skuName,
                                      String skuBarcode,String remarks, String syncType,String cateName,String brandName,Integer isSuccess) throws Exception {

        try {

            SyncProductLogs syncProductLogs  = new SyncProductLogs();

            syncProductLogs.setGoodsNo(goodsNo);
            syncProductLogs.setGoodsName(goodsName);

            syncProductLogs.setSkuName(skuName);
            syncProductLogs.setSkuBarcode(skuBarcode);

            syncProductLogs.setRemarks(remarks);
            syncProductLogs.setSyncType(syncType);
            syncProductLogs.setCreateTime(new Date());
            syncProductLogs.setIsSuccess(isSuccess);
            syncProductLogs.setCateName(cateName);
            syncProductLogs.setBrandName(brandName);

            boolean save = syncProductLogsService.save(syncProductLogs);

        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /******************* end ********************/
}
